<?php

	namespace app\common\model;

	use think\Model;

	class Base extends Model{

		private static $errorMsg;

		const DEFAULT_ERROR_MSG = '操作失败,请稍候再试!';

		/**
		 * 设置错误信息
		 * @param string $errorMsg
		 * @return bool
		 */
		protected static function setErrorInfo($errorMsg = self::DEFAULT_ERROR_MSG, $rollback = false){
			if ($rollback) self::rollback();
			self::$errorMsg = $errorMsg;
			return false;
		}

		/**
		 * 获取错误信息
		 * @param string $defaultMsg
		 * @return string
		 */
		public static function getErrorInfo($defaultMsg = self::DEFAULT_ERROR_MSG){
			return !empty(self::$errorMsg)?self::$errorMsg:$defaultMsg;
		}
	}